const express = require('express');
const router = express.Router();
const { protect } = require('../middleware/authMiddleware');
const {
  getUserDevices,
  getDeviceById,
  addDevice,
  updateDevice,
  deleteDevice,
  updateDeviceSync
} = require('../controllers/deviceController');

// 获取设备列表路由
router.route('/')
  .get(protect, getUserDevices)
  .post(protect, addDevice);

// 单个设备操作路由
router.route('/:id')
  .get(protect, getDeviceById)
  .put(protect, updateDevice)
  .delete(protect, deleteDevice);

// 设备同步时间更新路由
router.route('/:id/sync')
  .put(protect, updateDeviceSync);

module.exports = router; 